﻿using BlueWind.Mediator.ServiceContracts.Interfaces;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace BlueWind.Mediator.ServiceContracts
{
    public class Prototype : IPrototype<Prototype>
    {
        public Prototype Clone()
        {
            return (Prototype)this.MemberwiseClone();
        }

        public Prototype DeepCopy()
        {
            MemoryStream stream = new MemoryStream();
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(stream, this);
            stream.Seek(0, SeekOrigin.Begin);
            Prototype copy = (Prototype)formatter.Deserialize(stream);
            stream.Close();
            return copy;
        }
    }
}